﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;

using VxiUtil;

namespace VxiServer
{
    public class PolCommunication : TcpCommunication
    {
        protected override int Port
        {
            get { return 54001; }
        }

        protected override byte[] ProccessClientRequest(TcpClient client, byte[] request)
        {
            byte[] buffer = request;
            int receiveLength = 0;
            
            do
            {
                var code = GetPolCode(buffer[8]);
                if (code != null)
                {
                    code.Work(client, client.Client.GetIPAddress(), request);
                }

                receiveLength = client.Client.Receive(buffer);
            } while (receiveLength > 0);
            return null;            
        }


        private PolCode GetPolCode(byte flag)
        {
            switch (flag)
            {

                case 0x26:
                    return new PolCode0x26();
                default:
                    break;
            }
            return null;
        }
    }
}
